﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;
public partial class Manage_companyDonotSpeak : System.Web.UI.Page, HZ.MBSM.BLL.IPageDescribe
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string strSql, delInfoId;
        if (HZ.MBSM.BLL.Login.CheckAssert(this.UseAccountType))
        {
            if (Request.Form["btnSubmit"] == "删除" && Request.Form["chk"] != null)
            {
                delInfoId = Request.Form["chk"].ToString();
                strSql = "delete from CompanyDonotSpeak where accountid in (" + delInfoId + ")";
                Db db = new Db();
                db.Command(strSql);
                db.Close();
            }
           
            showGridView();
        }
       
    }
    /// <summary>
    /// 数据绑定
    /// </summary>
    public void showGridView()
    {
        string strConditions;
        strConditions = fctConditions();
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "CompanyDonotSpeak";                                               //要查询的表明
        dbPage.Key = "AccountId";                                               //表的主键    
        dbPage.Where = strConditions;                                           //查询条件    
        dbPage.SelectField = "AccountId,UserCode,CompanyName,addtime";//要显示的字段
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   
        dbPage.PageSize = 30;                                                    //没有显示记录条数   
        dbPage.OrderBy = "CompanyName";                  //排序字段
        System.Data.IDataReader dr = dbPage.ExecuteReader();
        DlInfo.DataSource = dr;
        DlInfo.DataBind();
        dr.Close();
        dr.Dispose();
        dbPage.Db.Close();
        db.Close();
        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键
    }
    /// <summary>
    /// 生成查询条件
    /// </summary>
    /// <returns></returns>
    public string fctConditions()
    {
        string strtemp = "", CompanyName = "", UserCode = "";
        int accountid = 0;
        UserCode = txtTitle.Text.Trim();
        CompanyName = TextBox1.Text.Trim();
        if (UserCode != "")
        {
            strtemp = strtemp + " UserCode like '%" + UserCode + "%' and";
        }
        if (CompanyName != "")
        {
            strtemp = strtemp + " CompanyName like '%" + CompanyName + "%' and";
        }
        if (strtemp != "")
        {
            strtemp = "  " + strtemp.Substring(0, strtemp.Length - 3);
        }
        return strtemp;

    }
 
    //protected void addcompany()//添加
    //{
    //    string strtemp = "", CompanyName = "", UserCode = "";
    //    int accountid = 0;
    //    UserCode = Request.Form["UserCode"];
    //    CompanyName = Request.Form["companyname"];
    //    if (Request.Form["id"] == "")
    //    {
    //        return;
    //    }
    //    accountid = Convert.ToInt32(Request.Form["id"]);
    //    strtemp = "select count(*) from CompanyDonotSpeak where accountid=" + accountid;
    //    Db db = new Db();
    //    DataTable da = db.DataTable(strtemp);
    //    if ((da.Rows[0].ItemArray[0].ToString().Trim() == "0")&&(accountid!=0))
    //    {
    //        strtemp = "insert into CompanyDonotSpeak values(" + accountid + ",'" + UserCode + "','" + CompanyName + "',getdate(),'')";
    //        int ii = db.Command(strtemp);
    //        if (ii == 1)
    //        {
    //            Response.Write("<script>alert('添加成功！');</script>");
    //        }
    //    }
    //    else
    //    {
    //        Response.Write("<script>alert('该企业已经在禁言中了！');</script>");
    //    }
    //    db.Close();
        
    //}
    #region IPageDescribe 成员

    public string Name
    {
        get { return "企业禁言管理"; }
    }

    public string Describe
    {
        get { return "企业禁言管理"; }
    }

    public string ParentName
    {
        get { return "企业禁言管理"; }
    }

    public System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> UseAccountType
    {
        get
        {
            System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAdmin);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
            return _AccountType;
        }
    }

    #endregion
   
}
